@import "./variables";

body {
  &.userLayout {
    overflow: auto;
  }
}

.layout.ant-layout {
  height: auto;
  overflow-x: hidden;

  &.mobile,
  &.tablet {
    .ant-layout-content {
      .content {
        margin: 24px 0 0;
      }
    }

    .top-nav-header-index {
      .header-index-wide {
        .header-index-left {
          .trigger {
            padding: 0 12px;
            color: rgba(255, 255, 255, 0.85);
          }

          .logo.top-nav-header {
            flex: 0 0 56px;
            line-height: 58px;
            text-align: center;

            h1 {
              display: none;
            }
          }
        }
      }

      &.light {
        .header-index-wide {
          .header-index-left {
            .trigger {
              color: rgba(0, 0, 0, 0.65);
            }
          }
        }

        //
      }
    }

    .ant-table-wrapper {
      .ant-table-content {
        overflow-y: auto;
      }

      .ant-table-body {
        min-width: 800px;
      }
    }

    .topmenu {
      /* 必须为 topmenu  才能启用流式布局 */

      &.content-width-Fluid {
        .header-index-wide {
          margin-left: 0;
        }
      }
    }
  }

  &.mobile {
    .sidemenu {
      .ant-header-fixedHeader {
        &.ant-header-side-opened,
        &.ant-header-side-closed {
          width: 100%;
        }
      }
    }
  }

  &.ant-layout-has-sider {
    flex-direction: row;
  }

  .trigger {
    padding: 0 24px;
    font-size: 20px;
    line-height: 64px;
    cursor: pointer;
    transition: color 0.3s;

    &:hover {
      background: rgba(0, 0, 0, 0.025);
    }
  }

  .topmenu {
    .ant-header-fixedHeader {
      position: fixed;
      top: 0;
      right: 0;
      z-index: 9;
      width: 100%;
      transition: width 0.2s;

      &.ant-header-side-opened {
        width: 100%;
      }

      &.ant-header-side-closed {
        width: 100%;
      }
    }

    /* 必须为 topmenu  才能启用流式布局 */

    &.content-width-Fluid {
      .header-index-wide {
        max-width: unset;

        .header-index-left {
          flex: 1 1 1000px;

          .logo {
            margin-left: 25px;
          }

          .ant-menu.ant-menu-horizontal {
            flex: 1 1 calc(100vw - 190px - 238px - 25px);
            max-width: calc(100vw - 190px - 238px - 25px);
          }
        }

        .header-index-right {
          margin-right: 25px;
        }
      }

      .page-header-index-wide {
        max-width: unset;
      }
    }
  }

  .sidemenu {
    .ant-header-fixedHeader {
      position: fixed;
      top: 0;
      right: 0;
      z-index: 9;
      width: 100%;
      transition: width 0.2s;

      &.ant-header-side-opened {
        width: calc(100% - 256px);
      }

      &.ant-header-side-closed {
        width: calc(100% - 80px);
      }
    }
  }

  .header {
    position: relative;
    height: 64px;
    padding: 0 12px 0 0;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  }

  .header,
  .top-nav-header-index {
    .user-wrapper {
      float: right;
      height: 100%;

      .action {
        display: inline-block;
        height: 100%;
        padding: 0 12px;
        color: rgba(0, 0, 0, 0.65);
        cursor: pointer;
        transition: all 0.3s;

        &:hover {
          background: rgba(0, 0, 0, 0.025);
        }

        .avatar {
          margin: 20px 8px 20px 0;
          color: #1890ff;
          vertical-align: middle;
          background: hsla(0, 0%, 100%, 0.85);
        }

        .icon {
          padding: 4px;
          font-size: 16px;
        }
      }
    }

    &.dark {
      .user-wrapper {
        .action {
          color: rgba(255, 255, 255, 0.85);

          a {
            color: rgba(255, 255, 255, 0.85);
          }

          &:hover {
            background: rgba(255, 255, 255, 0.16);
          }
        }
      }
    }
  }

  &.tablet {
    // overflow: hidden; text-overflow:ellipsis; white-space: nowrap;
    .top-nav-header-index {
      .header-index-wide {
        .header-index-left {
          .logo > a {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }

        .ant-menu.ant-menu-horizontal {
          flex: 1 1 auto;
          white-space: normal;
        }
      }
    }
  }

  .top-nav-header-index {
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
    transition: background 0.3s, width 0.2s;

    .header-index-wide {
      display: flex;
      max-width: 1200px;
      height: 64px;
      margin: auto;
      padding-left: 0;

      .ant-menu.ant-menu-horizontal {
        flex: 0 1 835px;
        max-width: 835px;
        height: 64px;
        line-height: 64px;
        border: none;
      }

      .header-index-left {
        display: flex;
        flex: 0 1 1000px;

        .logo.top-nav-header {
          position: relative;
          flex: 0 0 165px;
          width: 165px;
          height: 64px;
          overflow: hidden;
          line-height: 64px;
          transition: all 0.3s;

          img,
          svg {
            display: inline-block;
            width: 32px;
            height: 32px;
            vertical-align: middle;
          }

          h1 {
            display: inline-block;
            margin: 0 0 0 12px;
            color: #fff;
            font-weight: 400;
            font-size: 16px;
            vertical-align: top;
          }
        }
      }

      .header-index-right {
        flex: 0 0 238px;
        align-self: flex-end;
        height: 64px;
        overflow: hidden;

        .content-box {
          float: right;

          .action {
            max-width: 140px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }
      }
    }

    &.light {
      background-color: #fff;

      .header-index-wide {
        .header-index-left {
          .logo {
            h1 {
              color: #002140;
            }
          }
        }
      }
    }
  }

  // 内容区
  .layout-content {
    height: 100%;
    height: 64px;
    margin: 24px 24px 0;
    padding: 0 12px 0 0;
  }

  // footer
  .ant-layout-footer {
    padding: 0;
  }
}

// 顶部导航模式样式
.topmenu {
  .page-header-index-wide {
    max-width: 1200px;
    margin: 0 auto;
  }
}

// drawer-sider 自定义
.ant-drawer.drawer-sider {
  .sider {
    box-shadow: none;
  }

  &.dark {
    .ant-drawer-content {
      background-color: rgb(0, 21, 41);
    }
  }

  &.light {
    box-shadow: none;

    .ant-drawer-content {
      background-color: #fff;
    }
  }

  .ant-drawer-body {
    padding: 0;
  }
}

// 侧导航样式
.sider {
  position: relative;
  z-index: @ant-global-sider-zindex;
  min-height: 100vh;
  box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);

  .ant-layout-sider-children {
    overflow-y: hidden;

    &:hover {
      overflow-y: auto;
    }
  }

  &.ant-fixed-sidemenu {
    position: fixed;
    height: 100%;
  }

  .logo {
    position: relative;
    height: 64px;
    padding-left: 24px;
    overflow: hidden;
    line-height: 64px;
    background: #002140;
    transition: all 0.3s;

    img,
    svg,
    h1 {
      display: inline-block;
      vertical-align: middle;
    }

    img,
    svg {
      width: 32px;
      height: 32px;
    }

    h1 {
      margin: 0 0 0 12px;
      color: #fff;
      font-weight: 600;
      font-size: 20px;
      font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
      vertical-align: middle;
    }
  }

  &.light {
    background-color: #fff;
    box-shadow: 2px 0 8px 0 rgba(29, 35, 41, 0.05);

    .logo {
      background: #fff;
      box-shadow: 1px 1px 0 0 #e8e8e8;

      h1 {
        color: unset;
      }
    }

    .ant-menu-light {
      border-right-color: transparent;
    }
  }
}

// 外置的样式控制
.user-dropdown-menu {
  span {
    user-select: none;
  }
}

.user-dropdown-menu-wrapper.ant-dropdown-menu {
  padding: 4px 0;

  .ant-dropdown-menu-item {
    width: 160px;
  }

  .ant-dropdown-menu-item > .anticon:first-child,
  .ant-dropdown-menu-item > a > .anticon:first-child,
  .ant-dropdown-menu-submenu-title > .anticon:first-child .ant-dropdown-menu-submenu-title > a > .anticon:first-child {
    min-width: 12px;
    margin-right: 8px;
  }
}
